' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.12.16.16.28]) on 2024.02.16 at 21:36 (Coordinated Universal Time)
' Port and mod by Charlie Veniot
' of "Boxes" QBJS program by Vince (original program commented at the bottom of this listing)

dim sw, sh, d, z0, p, q
d = 300
z0 = 100

sw = 600
sh = 450
screen _newimage(sw, sh, 32)

declare sub box (x, y, z, w, l, h)
declare sub proj (x, y, z)

dim i, j
do
    cls

    j = j + 1
    for i=2 to 10
        color _rgb(0,255,0)    
        box(-50 + 100*sin((i + j)*0.1), 100, i*50, 50, 50, 50)
        box(50 + 100*sin((i + j)*0.1), 100, i*50, 50, 50, 50)
        color _rgb(255,255,0)    
        box(-50 + 100*sin((i + j)*0.1), 0, i*50, 50, 50, 50)
        box(50 + 100*sin((i + j)*0.1), 0, i*50, 50, 50, 50)
        color _rgb(0,255,255)    
        box(-50 + 100*sin((i + j)*0.1), -100, i*50, 50, 50, 50)
        box(50 + 100*sin((i + j)*0.1), -100, i*50, 50, 50, 50)
    next

    _delay 0.025
loop

sub box (x, y, z, w, l, h)
    proj (x - w/2, y - h/2, z - l/2)
    pset (p, q)
    proj (x + w/2, y + h/2, z - l/2)
    line -(p, q), ,b

    proj (x + w/2, y + h/2, z + l/2)
    line -(p, q)

    proj (x - w/2, y - h/2, z + l/2)
    line -(p, q), ,b

    proj (x - w/2, y - h/2, z - l/2)
    line -(p, q)

    proj (x - w/2, y + h/2, z - l/2)
    pset (p, q)
    proj (x - w/2, y + h/2, z + l/2)
    line -(p, q)

    proj (x + w/2, y - h/2, z - l/2)
    pset (p, q)
    proj (x + w/2, y - h/2, z + l/2)
    line -(p, q)

    'proj x, y, z
    'circle (p, q), 2, _rgb(255,255,0)
end sub

sub proj (x, y, z)
    p = sw/2 + x*d/(z + z0)
    q = sh/2 - y*d/(z + z0)
end sub

' 🟠🟠🟠 Vince's QBJS code 🟠🟠🟠

' dim shared sw, sh, d, z0, p, q
' d = 300
' z0 = 100
' sw = 800
' sh = 600
' screen _newimage(sw, sh, 32)
' dim i, j
' do
'     cls
'     'locate 1,1
'     'print _mousex, _mousey
'     'box 100, -100, 100, 50, 50, 20
'     'box -100, -100, 100, 50, 50, 20
'     j = j + 1
'     for i=2 to 10
'         box -50 + 100*sin((i + j)*0.1), -100, i*50, 50, 50, 50
'         box  50 + 100*sin((i + j)*0.1), -100, i*50, 50, 50, 50
'     next
'    _display
'    _limit 60
'loop
'sub box (x, y, z, w, l, h)
'    proj x - w/2, y - h/2, z - l/2
'    pset (p, q)
'    proj x + w/2, y + h/2, z - l/2
'    line -(p, q), ,b
'    proj x + w/2, y + h/2, z + l/2
'    line -(p, q)
'    proj x - w/2, y - h/2, z + l/2
'    line -(p, q), ,b
'    proj x - w/2, y - h/2, z - l/2
'    line -(p, q)
'    proj x - w/2, y + h/2, z - l/2
'    pset (p, q)
'    proj x - w/2, y + h/2, z + l/2
'    line -(p, q)
'    proj x + w/2, y - h/2, z - l/2
'    pset (p, q)
'    proj x + w/2, y - h/2, z + l/2
'    line -(p, q)
'    'proj x, y, z
'    'circle (p, q), 2, _rgb(255,255,0)
'end sub
'sub proj (x, y, z)
'    p = sw/2 + x*d/(z + z0)
'    q = sh/2 - y*d/(z + z0)
'end sub